<?php
require_once 'ini.php';

$order = new \admin\helper\order($register);
if ($_POST['act'] && $_POST['act'] == "erpTransport") {
    $order_id = $_POST['order_id'];
    $ret = $order->erpTransport($order_id);
    echo json_encode($ret);
    exit;
}
if(!$_SESSION['admin']['is_admin'])
{
    exit('无此权限');
}
$filter = [];
if ($_GET['order_no']) {
    $filter['OR'] = ['order_no' => trim($_GET['order_no']), 'erp_no' => trim($_GET['order_no'])];

}
if ($_GET['order_status']) {
    $filter['order_status'] = $_GET['order_status'];

}
if ($_GET['erp_status']) {
    $filter['erp_status'] = $_GET['erp_status'];
}
if ($_GET['name']) {
    $filter['name'] = trim($_GET['name']);
}
if ($_GET['title']) {
    $filter['title'] = trim($_GET['title']);
}
if ($_GET['domain']) {
    $filter['domain'] = trim($_GET['domain']);
}
if ($_GET['product_id']) {
    $filter['product_id'] = intval($_GET['product_id']);
}
if ($_GET['email']) {
    $filter['email'] = trim($_GET['email']);
}
if ($_GET['mobile']) {
    $filter['mobile'] = trim($_GET['mobile']);
}

$data = $order->orderList($filter);
$data['admin'] = $_SESSION['admin'];
$data['filter'] = $filter;

if( isset($_GET['json']) && $_GET['json'] == '1' ){
	echo json_encode($data);
}else{
	$register->get('view')->display('order_list.twig', $data);
}

